package com.lg.timeApi;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.junit.Test;

public class TestTimeApi {
	@Test
	public void ssss() {
		
	  Calendar instance = Calendar.getInstance();
	  instance.setTimeInMillis(new Date().getTime());
	  GregorianCalendar gcalendar = new GregorianCalendar();
	  boolean leapYear = gcalendar.isLeapYear(2010);
	  System.out.println(leapYear);
	}
	@Test
	public void sss() {
		
		String a = "aBCd12";
		char[] charArray = a.toCharArray();
		for (char string : charArray) {
			System.out.print(string + " isDigit ：" + Character.isDigit(string) + " isLetter  ： " + Character.isLetter(string)
					);
			if (Character.isLetter(string)) {
				System.out.println("  is up： " + Character.isUpperCase(string));
			}
		}
	}

	@Test
	public void ss() {

		// 获取当前时间日期
		ZonedDateTime date1 = ZonedDateTime.parse("2015-12-03T10:15:30+05:30[Asia/Shanghai]");
		ZonedDateTime withSecond = ZonedDateTime.now().withYear(2018).withMonth(12).withDayOfMonth(12).withHour(12)
				.withMinute(30).withSecond(12);
		System.out.println("date1: " + date1.isBefore(withSecond));
		System.out.println("date1: " + withSecond.isAfter(date1));

		ZoneId id = ZoneId.of("Europe/Paris");
		System.out.println("ZoneId: " + id);

		ZoneId currentZone = ZoneId.systemDefault();
		System.out.println("当期时区: " + currentZone);
	}

	@Test
	public void testLocalDateTime1() {
		LocalDate now = LocalDate.of(2014, Month.DECEMBER, 12);
		;
		System.out.println("currentTime:" + now);
		System.out.println("currentTime getYear:" + now.getYear());
		System.out.println("currentTime getMonth:" + now.getMonth());
		System.out.println("currentTime getMonthValue:" + now.getMonthValue());
		System.out.println("currentTime getDayOfYear:" + now.getDayOfYear());
		System.out.println("currentTime getDayOfMonth:" + now.getDayOfMonth());
		System.out.println("currentTime getDayOfWeek:" + now.getDayOfWeek().getValue());
		// 22 小时 15 分钟
		LocalTime date4 = LocalTime.of(22, 15);
		System.out.println("date4: " + date4);
		// 解析字符串
		LocalTime date5 = LocalTime.parse("20:15:30");
		System.out.println("date5: " + date5);
	}

	@Test
	public void testLocalDateTime() {
		LocalDateTime now = LocalDateTime.now();
		System.out.println("currentTime:" + now);
		System.out.println("currentTime LocalDate:" + now.toLocalDate());
		System.out.println("currentTime LocalTime:" + now.toLocalTime());
		System.out.println("currentTime getYear:" + now.getYear());
		System.out.println("currentTime getMonth:" + now.getMonth());
		System.out.println("currentTime getMonthValue:" + now.getMonthValue());
		System.out.println("currentTime getDayOfYear:" + now.getDayOfYear());
		System.out.println("currentTime getDayOfMonth:" + now.getDayOfMonth());
		System.out.println("currentTime getDayOfWeek:" + now.getDayOfWeek().getValue());
		System.out.println("currentTime getHour:" + now.getHour());
		System.out.println("currentTime getMinute:" + now.getMinute());
		System.out.println("currentTime getSecond:" + now.getSecond());
		LocalDateTime withYear = now.withDayOfMonth(10).withYear(2012).withMonth(11);
		System.out.println(" withYear currentTime:" + withYear);
		System.out.println(" withYear currentTime LocalDate:" + withYear.toLocalDate());
		System.out.println(" withYear currentTime LocalTime:" + withYear.toLocalTime());
		System.out.println(" withYear currentTime getYear:" + withYear.getYear());
		System.out.println(" withYear currentTime getMonth:" + withYear.getMonth());
		System.out.println(" withYear currentTime getMonthValue:" + withYear.getMonthValue());
		System.out.println(" withYear currentTime getDayOfYear:" + withYear.getDayOfYear());
		System.out.println(" withYear currentTime getDayOfMonth:" + withYear.getDayOfMonth());
		System.out.println(" withYear currentTime getDayOfWeek:" + withYear.getDayOfWeek().getValue());
		System.out.println(" withYear currentTime getHour:" + withYear.getHour());
		System.out.println(" withYear currentTime getMinute:" + withYear.getMinute());
		System.out.println(" withYear currentTime getSecond:" + withYear.getSecond());

	}
}
